<?php

/**
 * This is the model class for table "{{text_emotion}}".
 *
 * The followings are the available columns in table '{{text_emotion}}':
 * @property integer $id
 * @property integer $text_id
 * @property integer $emotion_id
 * @property integer $quantidade
 */
class TextEmotion extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return TextEmotion the static model class
	 */
	public $lang;
	public $texto;
	public $arquivo;
	
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{text_emotion}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('text_id, emotion_id, quantidade', 'required'),
			array('text_id, emotion_id', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, text_id, emotion_id, quantidade', 'safe', 'on'=>'search'),
		);
	}


	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'text_id' => 'Text',
			'emotion_id' => 'Emotion',
			'quantidade' => 'Quantidade',
		);
	}
	
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
				'text' => array(self::BELONGS_TO, 'Text', 'text_id'),
				'emotion' => array(self::BELONGS_TO, 'Emotion', 'emotion_id')
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('text_id',$this->text_id);
		$criteria->compare('emotion_id',$this->emotion_id);
		$criteria->compare('quantidade',$this->quantidade);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}